home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Developer Helper 1: Phil & Dave's Excellent CD
/
Excellent CD HFS.raw
/
Moof
/
Goodies
/
MPW Goodies
/
MPW Goodies⁄DTS
/
CheckWindowIn
< prev
next >
Wrap
Text File
|
2022-08-05
|
4KB
|
155 lines
# CheckWindowIn - check a window in
#
# Usage: CheckWindowIn window
#
# Status: CheckWindowIn may return the following status values:
#
# 0 the window was checked in
# 1 error
# 4 the user canceled
#
# CheckWindowIn presents a dialog that allows the user to type
# in a short comment that indicates what changes have been made
# to the file since it was checked out. These will be logged into
# the project, and, if the file has a LastChange marker, will be
# logged into the file.
#
# © 1988, 1989 Apple Computer, Inc.
# All rights reserved.
Set Exit 0
# the following helps to debug until MPW sends echos to Dev:Console instead of Dev:StdErr
If {Echo} == 1
Set somewhere "∑∑ '{Worksheet}∂'"
Else
Set somewhere '∑ Dev:Null'
End
Begin
Set OldComment "{SystemFolder}OldComment"
Set NewComment "{SystemFolder}NewComment"
Set CheckInErrors "{SystemFolder}CheckInErrors"
Set Window "{1}"
# get short name of window
If "{Window}" !~ /:*([¬:]+:*)*([¬:]+)®1/
Exit 1 # bad window parameter
End
Set Short "{®1}" # get short name for dialogs
Set Cant "“{Short}” can’t be checked in"
# check what project the window belongs to
# *** what about a files that are new to a project?
Set Info "`ProjectInfo "{Window}"`"
Unset New
Unset Version
### If "{Info}" !~ /≈Project: (≈∫)®1 ≈/
If "{Info}" !~ /≈Project: (≈)®1 Checked out: ≈/
If `Project` == ""
Alert "{Cant} because there are no projects mounted."
Exit 1
End
Set New "-new -project `GetListItem -r 10 ∂`MountProject -pp -s -r∂` -d ∂`Project∂` ∂
-m "“{Short}” isn’t in a project. Choose one to add it to:" ; Set GetListItemStatus {Status}`"
If {GetListItemStatus} != 0
Exit 1
End
If "{InitialVersion}" != ""
Set Version ",{InitialVersion}"
End
Else
Set Project "{®1}"
# check if the project is mounted
ProjectInfo -project "{Project}" -only
If {Status} != 0
Alert "{Cant} because the project “{Project}” is not mounted."
Exit 1
End
# ensure that the window is checked out
If "{Info}" !~ /[¬,]+,[¬ ∂t]+[∂+∂*]≈/
Alert "{Cant} because it wasn’t checked out."
Exit 1
End
End
Echo -n >"{OldComment}" # start with an empty file
If {ProjectHeaders}
Mark -y § OldSelection "{Window}" # mark the selection
GetLastChange "{Window}" "{OldComment}"
End
If ({Status} ≠ 0) || ¬ {ProjectHeaders}
Set Info "`ProjectInfo "{Window}" -comments`"
If "{Info}" =~ /≈Comment: +(≈)®1/
Echo -n "{®1}" >"{OldComment}"
End
End
Set IgnoreCmdPeriod 1
CoolRequest -q -d "What did you change in “{Short}”?" <"{OldComment}" >"{NewComment}"
Set CommentStatus {Status}
Set IgnoreCmdPeriod 0
Equal -d -q "{OldComment}" "{NewComment}"
Set EqualStatus {Status}
Delete -i "{OldComment}"
If {CommentStatus} != 0
If {ProjectHeaders}
Find OldSelection "{Window}"
Unmark OldSelection "{Window}"
End
Delete -i "{NewComment}"
If {CommentStatus} == 4
Exit 4
End
Exit 1
End
If {ProjectHeaders}
If {EqualStatus}
# add/modify a change in the change history
Evaluate "`Files -n -q -x m "{Window}"`" =~ /[¬∂/]+ ([1-9]≈)®1/
Set Date "{®1}" # get date before adding change
Clear LastChange "{Window}" # get rid of old change
AddChange "{Window}" "{NewComment}"
Set AddChangeStatus {Status} # remember if we canceled
Find • "{Window}" # go to top
Replace -c ∞ /[ ∂t]+∞/ '' "{Window}" # trim all trailing whitespace
SetFile -m "{Date}" "{Window}" # set date back to before change
End
Find OldSelection "{Window}"
Unmark OldSelection "{Window}"
Save "{Window}" # save before checking in
If {AddChangeStatus} == 4
Exit 4
End
End
# *** what about a way to keep working (keep the modifiable)?
# *** what about introducing a new branch?
# *** what about entering a "task"?
CheckIn {New} -cf "{NewComment}" "{Window}{Version}" ∑"{CheckInErrors}"
Set CheckInStatus {Status}
Delete -i "{NewComment}"
If {CheckInStatus} != 0
Alert "{Cant}. You may need to check it in on a branch.∂n`Catenate "{CheckInErrors}"`"
Exit 1
End
Delete -i "{CheckInErrors}"
End {somewhere}